var t = require('../@babel/runtime/helpers/regeneratorRuntime.js'),
  a = require('../@babel/runtime/helpers/asyncToGenerator.js'),
  e = require('D28B336470B67DCFB4ED5B639AB21B27.js'),
  r = getApp();
module.exports = Behavior({
  properties: {},
  data: {},
  pageLifetimes: { show: function () {} },
  created: function () {},
  attached: function () {},
  ready: function () {},
  methods: {
    __draw2: function (o) {
      var h = this;
      return a(
        t().mark(function a() {
          var i, n, l, s, f, c, d, u, p;
          return t().wrap(function (t) {
            for (;;)
              switch ((t.prev = t.next)) {
                case 0:
                  return (
                    (i = h),
                    (n = h.data),
                    (l = n.pure_tabOne),
                    n.pure_nickname,
                    (s = o.box_bg),
                    (f = o.QRimg),
                    o.logo,
                    (c = o.userBg),
                    (d = o.thumb),
                    (u = h.data.pure_rpx),
                    (p = wx.createCanvasContext('shareAd', h)),
                    750,
                    1616,
                    t.abrupt(
                      'return',
                      new Promise(function (t, a) {
                        p.drawImage(
                          s.path,
                          0,
                          0,
                          s.width,
                          s.height,
                          0,
                          0,
                          Math.floor(750 * u),
                          Math.floor(1616 * u),
                        ),
                          p.save(),
                          (p.font = '500 24px DIN');
                        var o = h.handName(p);
                        p.beginPath(),
                          o.wasCrop
                            ? p.drawImage(
                                c.path,
                                0,
                                0,
                                c.width,
                                c.height,
                                Math.floor(22 * u),
                                Math.floor(36 * u),
                                Math.floor(362 * u),
                                Math.floor(56 * u),
                              )
                            : (e.canvas_roundRect(
                                p,
                                Math.floor(22 * u),
                                Math.floor(36 * u),
                                Math.floor((76 + o.width) * u),
                                Math.floor(56 * u),
                                Math.floor(28 * u),
                                !1,
                              ),
                              p.clip(),
                              p.drawImage(
                                c.path,
                                0,
                                0,
                                c.width,
                                c.height,
                                Math.floor(22 * u),
                                Math.floor(36 * u),
                                Math.floor(362 * u),
                                Math.floor(56 * u),
                              ),
                              p.restore()),
                          p.save(),
                          p.beginPath(),
                          p.arc(50 * u, 64 * u, 24 * u, 0, 2 * Math.PI),
                          p.clip(),
                          p.drawImage(
                            d.path,
                            0,
                            0,
                            d.width,
                            d.height,
                            Math.floor(26 * u),
                            Math.floor(40 * u),
                            Math.floor(48 * u),
                            Math.floor(48 * u),
                          ),
                          p.restore(),
                          (p.font = '500 24px DIN'),
                          (p.fillStyle = '#fff'),
                          (p.font = '500 '.concat(
                            Math.floor(24 * u),
                            'px DIN',
                          )),
                          p.fillText(o.text + '的微折购小店', 81 * u, 72 * u),
                          p.save(),
                          p.beginPath();
                        p.drawImage(
                          f.path,
                          0,
                          0,
                          f.width,
                          f.height,
                          239 * u,
                          1205 * u,
                          270 * u,
                          270 * u,
                        ),
                          p.save();
                        var n = '长按图片识别二维码';
                        if (
                          d.pure_src.includes(r.CONFIG.DEFAULT_AVATAR) ||
                          f.pure_src.includes('default')
                        ) {
                          n = d.pure_src.includes(r.CONFIG.DEFAULT_AVATAR)
                            ? '请登录后重新获取'
                            : '请重新获取分享图片';
                          var M = i.data.reloadBtnMap;
                          (M[l.share_id] = !0), i.setData({ reloadBtnMap: M });
                        } else {
                          var g = i.data.reloadBtnMap;
                          (g[l.share_id] = !1),
                            i.setData({ reloadBtnMap: g }),
                            p.beginPath(),
                            p.arc(375 * u, 1339 * u, 57 * u, 0, 2 * Math.PI),
                            p.clip(),
                            p.drawImage(
                              d.path,
                              0,
                              0,
                              d.width,
                              d.height,
                              Math.floor(318 * u),
                              Math.floor(1282 * u),
                              Math.floor(114 * u),
                              Math.floor(114 * u),
                            ),
                            p.restore();
                        }
                        (p.font = '500 '.concat(Math.floor(24 * u), 'px DIN')),
                          (p.fillStyle = '#666666'),
                          p.fillText(n, 270 * u, 1514 * u),
                          p.draw(!1, function (a) {
                            'drawCanvas:ok' === a.errMsg
                              ? setTimeout(function () {
                                  wx.canvasToTempFilePath(
                                    {
                                      destWidth: 2250,
                                      destHeight: 4848,
                                      quality: 0.78,
                                      fileType: 'jpg',
                                      canvasId: 'shareAd',
                                      success: function (a) {
                                        t(a.tempFilePath);
                                      },
                                    },
                                    i,
                                  );
                                }, 100)
                              : (console.error('WTF draw callback!!'),
                                setTimeout(function () {
                                  wx.canvasToTempFilePath(
                                    {
                                      destWidth: 2250,
                                      destHeight: 4848,
                                      quality: 0.78,
                                      fileType: 'jpg',
                                      canvasId: 'shareAd',
                                      success: function (a) {
                                        t(a.tempFilePath);
                                      },
                                    },
                                    i,
                                  );
                                }, 300));
                          });
                      }),
                    )
                  );
                case 8:
                case 'end':
                  return t.stop();
              }
          }, a);
        }),
      )();
    },
  },
});
